﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Data;

namespace CS424_9pts
{
    public partial class CheckoutShippingMethod : System.Web.UI.Page
    {
        int id;
        DataTable dt;
        DataView dv;
        protected void Page_Load(object sender, EventArgs e)
        {
            id = 0;
            if (Session["UserId"] == null)
                Response.Redirect("Account/Login.aspx");

            dv = (DataView)GetShippingMethods.Select(DataSourceSelectArguments.Empty);
            dt = dv.ToTable();

            foreach (DataRow row in dt.Rows)
            {
                string str = row["MethodName"] + " (" + row["Price"] + "USD)";

                rdl.Items.Add(str);
            }
           // dlShippingOptions.SelectedIndex = 0;
        }

        protected void btnNext_Click(object sender, EventArgs e)
        {
            int method = Int32.Parse(dt.Rows[rdl.SelectedIndex]["ShippingMethodId"].ToString());
            Session["ShippingMethod"] = method;        
            Session["ShippingPrice"] = dt.Rows[method]["Price"];
            Response.Redirect("CheckoutPaymentMethod.aspx");
        }
    }
}